#include <stdio.h>
#include <string.h>

#include <limits.h>

#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <poll.h>

#ifndef OPEN_MAX
#define OPEN_MAX 255
#endif

typedef struct sockaddr_in sockaddr_in;
typedef struct sockaddr sockaddr;

int main()
{
	char wr_buf[4098] = {0};
	struct pollfd client[1];
	int fd = socket(AF_INET, SOCK_STREAM, 0);

	sockaddr_in svr_addr;
	svr_addr.sin_family = AF_INET;
	svr_addr.sin_addr.s_addr = inet_addr("192.168.1.111");
	svr_addr.sin_port = htons(62400);
	
	client[0].fd = fd;
	client[0].events = POLLRDNORM;

	connect(fd, (sockaddr *)&svr_addr, sizeof(sockaddr));

	int total_len = 10;
	while(1)
	{
		sprintf(wr_buf, "%d send total len is %d", fd, total_len);
		printf("%s\n", wr_buf);
		total_len += send(fd, wr_buf, strlen(wr_buf), 0);

		getchar();

		usleep(1000);
	}

	return 0;
}